ifeq ($(TARGETNAME),)
	TARGETEXE := $(shell basename $(shell pwd))
else
	TARGETEXE := $(TARGETNAME)
endif

TARGETSO := lib$(TARGETEXE).so

LIBS    :=
LDFLAGS:= 
DEFINES:=

INCLUDE	:= $(APP_INCLUDE)
CFLAGS  := $(APP_CFLAGS)
CXXFLAGS:= $(CFLAGS)
LINKFLAGS := $(APP_LINKFLAGS)

SOSHARE   := -shared -o
EXESHARE  := -o
OBJS_DIR  := ../out/objs

#settting source search path
vpath %.cpp .:inonectrl:userctrl
vpath %.c  .:inonectrl:userctrl
vpath %.cc .:inonectrl:userctrl
vpath %.h .:inonectrl:userctrl

#i think you should do anything here,if have other c /cc source,please put it on ./ or userctrl path
SOURCE  := \
			$(wildcard ./inonectrl/*.cpp) \
			$(wildcard ./*.c) \
			$(wildcard ./*.cc) \
			$(wildcard ./*.cpp) \
			$(wildcard ./userctrl/*.c) \
			$(wildcard ./userctrl/*.cc) \
			$(wildcard ./userctrl/*.cpp)
			
			
OBJS    := $(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCE))))
OBJS_WITHOUT_DIR = $(notdir $(OBJS))
OBJS_WITH_DIR = $(addprefix $(OBJS_DIR)/,$(OBJS_WITHOUT_DIR))

.PHONY : release debug clean genexe genso
 
release : $(TARGETSO)
	$(STRIP) $(TARGETSO)
	$(MV) $(TARGETSO) $(RELEASE_APPDIR)

debug : $(TARGETSO)
	$(MV) $(TARGETSO) $(RELEASE_APPDIR)
	
genexe : $(TARGETEXE)
	$(STRIP) $(TARGETEXE)
	
genso : $(TARGETSO)
	$(STRIP) $(TARGETSO)
	$(MV) $(TARGETSO) $(RELEASE_APPDIR)
               
clean :
	$(RM) $(OBJS_WITH_DIR)
	$(RM) $(RELEASE_APPDIR)/$(TARGETSO)
	
$(TARGETEXE): $(OBJS_DIR) $(OBJS_WITH_DIR)
	$(CXX) $(CXXFLAGS) $(OBJS_WITH_DIR) $(LDFLAGS) $(LINKFLAGS) $(EXESHARE) $@ 
	
$(TARGETSO): $(OBJS_DIR) $(OBJS_WITH_DIR)
	$(CXX) $(CXXFLAGS) $(OBJS_WITH_DIR) $(LDFLAGS) $(LINKFLAGS) $(SOSHARE) $@ 
	
$(TARGETSTRIP): $(OBJS_DIR) $(OBJS_WITH_DIR)
	$(CXX) $(CXXFLAGS) $(OBJS_WITH_DIR) $(LDFLAGS) $(LINKFLAGS) $(SOSHARE) $@ 
    	
$(OBJS_DIR):
	$(MKDIR) $(OBJS_DIR)
	
$(OBJS_DIR)/%.o:%.c
	$(CC) $(CFLAGS) -c $< -o $@
	
$(OBJS_DIR)/%.o:%.cpp
	$(CXX) $(CXXFLAGS) -c $< -o $@
	
$(OBJS_DIR)/%.o:%.cc
	$(CXX) $(CXXFLAGS) -c $< -o $@